var UserService = RestfulService.extend({
	SERVICE_URL : 'api/admin/users',
	
	get : function(successcb, errorcb) {
		return this._get(this.SERVICE_URL, successcb, errorcb);
	},
	
	save : function(user, successcb, errorcb) {
		return this._post(this.SERVICE_URL, user,  successcb, errorcb);
	},
	
	update : function(user, successcb, errorcb) {
		return this._put(this.SERVICE_URL + '/' + user.username, user, successcb, errorcb);
	},
	
	remove : function(username, successcb, errorcb) {
		return this._delete(this.SERVICE_URL + '/' + username, successcb, errorcb);
	},
	
	getById : function(username, successcb, errorcb) {
		return this._get(this.SERVICE_URL + '/' + username, successcb, errorcb);
	},
	
	getBySession : function(successcb, errorcb) {
		return this._get('api/usersession', successcb, errorcb);
	},
	
	
	isExistedUser : function(name, value, successcb, errorcb) {
		var queryURL = this.SERVICE_URL + '/q?k=' + name + "&v=" + value;
		
		return this._get(queryURL, successcb, errorcb);
	},
	
	resetPassword : function(resetInfo, successcb, errorcb) {
		return this._put(this.SERVICE_URL + '/' + resetInfo.username + '/reset-password', resetInfo, successcb, errorcb);
	}
});

(function () {
	var UserServiceProvider = Class.extend({
		instance : new UserService(),
		
		$get : [ '$http', '$rootScope','SharedVariableService', function($http, $rootScope, SharedVariableService) {
			this.instance.$http = $http;
			this.instance.SharedVariableService = SharedVariableService;
			
			return this.instance;
		} ]
	})
	angular.module('system.UserService', []).provider('UserService', UserServiceProvider);
}())














